Skip to content

Victron: add grid-setpoint battery hold control (#31099)#31299

Draft
t0mas wants to merge 1 commit into
evcc-io:masterfrom
t0mas:feature-alternative-victron-battery-hold-control
Draft

Victron: add grid-setpoint battery hold control (#31099)#31299
t0mas wants to merge 1 commit into
evcc-io:masterfrom
t0mas:feature-alternative-victron-battery-hold-control

Conversation

@t0mas

@t0mas t0mas commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

See issue #31099. The minimum-SOC based approach conflicts with Victron DESS. This adds an optional approach to adjust the battery setpoint by the current EVCC charging power so the battery ignores it.

@florian240483

Copy link
Copy Markdown

Is this only relevant for hold discharge mode or also the other modes? (Hold charge, force charge)

@t0mas

t0mas commented Jun 28, 2026

Copy link
Copy Markdown
Contributor Author

We could use the same method for each of them. The tricky part is that a Victron system typically operates based on a grid setpoint unless you put it in very low level control mode. So the concept of hold charge/discharge is not that easy to implement. This method does it by increasing the grid setpoint by the amount of power being used for charging.

A force charge in Victron terms means setting the grid setpoint to for example 5 kW import, and then the battery charges with 5 kW minus the household usage.

@florian240483

Copy link
Copy Markdown

I've also thought about how to control the battery modes via the grid-setpoint, since I don't think the current implementation is ideal either.

I've already tested the battery modes using grid-setpoint, by manually writing to the registers via ModbusPoll, and I can share my observations and findings here in case that might be helpful. I think for implementing batterymodes such as hold charge oder hold discharge, other registers that activate/deactivate the inverter or charger might be the way to go. Controlling this via the grid-setpoint seems to me to be a very complicated solution?

Regarding Force Charge: If the grid setpoint is set high enough, the charger will either charge the battery at its maximum power or the charge will be limited by the maximum charge current set via the DVCC-settings. The same would apply to the “Force Discharge” mode (should it ever become relevant). The only difference is that in this case, the inverter power can be limited in the UI. I think these two settings - maximum inverter power and maximum charging current—should definitely be taken into account by the battery modes.

@t0mas

t0mas commented Jun 29, 2026

Copy link
Copy Markdown
Contributor Author

Yes let's compare notes. I had looked into limiting inverter power (and similar registers for limiting charge power), however these seem to have other side-effects. For example inverter power could also effect functionality like peak-shaving. And changing DVCC charge current is only half the equation because that number includes current from the MPPT as well so you would have do calculate a continuously changing target number to be able to use it to control the amount of AC power the inverters take.

The grid setpoint is listed in the Victron documentation as usable for "mode 2" control which will leave all other settings alone and respect all limits. There is also "mode 3" which allows you to do whatever you want, but then you're responsible for managing limits.

In mode 2, if you set the grid setpoint +20000 or -20000 or something the system will take that as a request to charge or discharge at the maximum rate. That maximum depends on inverter capability (and temperature), it automatically takes BMS signals from the batteries about maximum charge/discharge into account and adjusts for any PV input via the MPPT. So it's a very managed mode.

@florian240483

Copy link
Copy Markdown

I also tested Mode 3, but I quickly came to the conclusion that it would be even more complicated, especially if it's supposed to work with a wide variety of Victron systems. So i guess mode 2 is fine. I will have a look at my notes in the evening and we can check again.

@florian240483

Copy link
Copy Markdown

I used in my verfication the following registers:
image

The battery-modes are then described in the following pattern:

Hold Discharge (old: battery hold):
• Reg 2702: 0 (disables feed in, but does not affect the configured max inverter power conifgured in the Victron UI)

Force Charge:
• Reg 2716: -100000 (representative value)

Hold Charge:
• Without DVCC: Reg 2701 = 0
• With DVCC: Reg 2705 = 0 (Reg 2701 does not work in this case)

Normal Operation:
• Reg 2701: 100 (dont know if that fits for all users, because i can not test the scenario without DVCC)
• Reg 2705: set to Max. Charging Current that has to be configured in evcc-Konfig (-1, if no charge current limit)
• Reg 2702: 100
• Reg 2716: 0 (grid-setpoint)

When writing to register 2716, the inverter regulates the AC side to this setpoint. The grid setpoint, which is set in the UI and stored in register 2700, is overruled but not overwritten. If the ESS is to return to normal operation, register 2716 must be reset either to the value stored in register 2700 or, if this is not possible in the templates, for example, to 0 watts (zero feed-in).
Furthermore, I recognized that the value written to register 2716 is reset after approximately 5 minutes. From that point on, the control system reverts to using the grid setpoint value configured in the Victron UI. This means that writing a 0 by default would be a good approach here. If this does not quite match the user’s desired setpoint, it will reset automatically after a short time anyway.

Advantages of this implementation would be: The maximum battery charge current set in the DVCC menu is taken into account. The inverter power limit is taken into account. The SOC limit is not changed and remains active. Works for 1- and 3-phase systems.

I have not yet investigated the behavior on peak shaving.

@t0mas

t0mas commented Jun 29, 2026

Copy link
Copy Markdown
Contributor Author

Thanks! My observations for 2716 are the same as yours. And writing 0 back into it means the device will start to do whatever the user has set in 2700 via the UI, so that is a safe way to return it to normal. That is better than writing the value of 2700 into 2716, because doing so looks like it would override a later change by the user (via the Victron UI).

Unfortunately 2701 and 2702 both are deprecated and documented by Victron here https://www.victronenergy.com/live/ess:ess_mode_2_and_3 as "This setting is deprecated and only works when DVCC is disabled." so we cannot use those.

I'm not a fan of changing 2705 dynamically from EVCC. That setting is part of the Charge Control screen with a "Caution: Read the manual before adjusting" label. It needs to be set to a safe value for the batteries, fuses and cables. It's also in amps, so we would need to consider the battery voltage (not all are 48V systems).

@florian240483

florian240483 commented Jun 29, 2026

Copy link
Copy Markdown

So our solutions to force charge via Register 2716 are the same. That’s a first success, i think.

I'm quite familiar with Victron's description of the ESS modes, but I couldn't come up with any other solution for implementing the Hold Discharge or Hold Charge mode. For Hold Discharge we could also use 2704 instead of 2702 to disable the inverter, but then a inverter-power-limit has to be configured in the evcc-template? Thats why i tried to use Reg 2702. I know its deprecated, but it does still work and has the advantage that we dont override user-settings in the Victron-UI and an additional config-value in evcc is also not necessary.

I totally agree with you that disabling the charger via the Register 2701 or 2705 is not a very elegant solution, but as described above, im not sure how to do it in a better way. But for BMS-controlled ESS-Systems this charge current limitation is not a must have, because the bms of the battery does already limit its charge current. As I understand it right, it is intended solely to protect batteries that are not managed by a BMS, rather than to protect cables or fuses against overload. That is part of a proper electrical installation.

I also considered for Hold Charge-mode to use ESS-Mode 3 and disable the charger, but in this case a user defined inverter-power limit would not be considered if a DC-coupled pv-power is fed into the grid.

@t0mas

t0mas commented Jun 29, 2026

Copy link
Copy Markdown
Contributor Author

Agree, there is not really a clean way to do Hold Charge and Hold Discharge with the options that Victron offers if you want to stay in mode 2 (which I think we do, because mode 3 also looses other protections).

We could use 2704 to do a "Don't Discharge" mode by setting it to 0, it may be better than doing the current minSOC = SOC (which breaks DESS, see #31299). However I expect that it will break Peak Shaving. That is tricky because Peak Shaving is a feature you would mostly use when the EV is charging, which is exactly when EVCC would want to use a "Don't discharge" mode.

So these considerations is how I got to the approach of writing current EV charge power into 2716. Then all other features keep working and the battery essentially ignores the EV charger while still charging from solar and discharging for household loads.

@florian240483

florian240483 commented Jun 30, 2026

Copy link
Copy Markdown

As i unterstand peak shaving correctly, but that sounds like a contradiction to me. Either I want the home battery not to discharge during an ev-charging process, drawing energy from the grid instead. Or I want to limit the power drawn from the grid by using the battery for support. You can't do both during an EV-charging session.

And the second question is, does peak shaving work with the current minSOC = SOC solution?

And in addition, there is also the load management feature, that could take on this task.

@t0mas

t0mas commented Jun 30, 2026

Copy link
Copy Markdown
Contributor Author

It does work with minSOC = SOC.

Typically peak shaving uses only small amounts of total energy discharged but in short bursts with high peak powers. So the overall cost in kWh is very low, but disabling it can cause issues.

I need to find a moment to test the exact interaction between limiting inverter power via modbus and the peak shaving logic. I expect at that it will still reduce charging power if it was charging at the time of the overload. And I expect it won't discharge above the inverter power limit. At least that's how I read the Victron docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants